package com.mxpio.erp.common.asset.entity;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.*;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpio.erp.common.inventory.entity.Warehouse;
import com.mxpio.erp.common.technology.entity.Item;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;

import com.mxpioframework.security.entity.Dept;
import com.mxpioframework.security.entity.User;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_ASSET_BR_MATERIAL_FLOW")
@Schema(description = "物资借用/归还流水")
public class BorrowOutMaterialFlow  extends BaseEntity {
	private static final long serialVersionUID = 1L;

	@Id
	@Column(name = "ID_", updatable = false)
	@Generator
	@Schema(description = "流水号")
	private String id;

	@Column(name = "ACCESS_TYPE_")
	@Schema(description = "出入类型")
	private String accessType;

	@Column(name = "ITEM_CODE_")
	@Schema(description = "物料代码")
	private String itemCode;

	@Column(name = "QUANTITY_")
	@Schema(description = "数量")
	private BigDecimal quantity;

	@Column(name = "LOT_NO_")
	@Schema(description = "批次号")
	private String lotNo;

	@Column(name = "ORIGIN_BIZ_NO_")
	@Schema(description = "来源单号")
	private String originBizNo;

	@Column(name = "ORIGIN_BIZ_TYPE_")
	@Schema(description = "来源单据类型")
	private String originBizType;

	@Column(name = "ORIGIN_BIZ_LINE_NO_")
	@Schema(description = "来源单行号")
	private String originBizLineNo;

	/*@Column(name = "WO_BIZ_NO_")
	@Schema(description = "仓单单号")
	private String woBizNo;

	@Column(name = "WO_BIZ_LINE_NO_")
	@Schema(description = "仓单行号")
	private String woBizLineNo;

	@Column(name = "WO_BIZ_TYPE_")
	@Schema(description = "仓单类型")
	private String woBizType;*/

	@Column(name = "WH_CODE_")
	@Schema(description = "仓库编号")
	@Dict(dicCode = "whCode" ,dicEntity = Warehouse.class, dicText = "whName")
	private String whCode;

	@Column(name = "MEMO_")
	@Schema(description = "备注")
	private String memo;


/*	@Column(name = "OPT_TYPE_")
	@Schema(description = "操作类型(0借出/1归还)")
	private String optType;*/


	@Column(name = "OPT_MAN_")
	@Schema(description = "操作人")
	@Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
	private String optMan;

	@Transient
	@Schema(description = "物料名称")
	private String itemName ;

	@Transient
	@Schema(description = "规格型号")
	private String itemSpec ;

	@Transient
	@Schema(description = "单位编号")
	private String unitCode;

	@Transient
	@Schema(description = "物料图片")
	private String imgFile ;

	@Transient
	@Schema(description = "借用人")
	@Dict(dicCode = "username", dicEntity = User.class, dicText = "nickname")
	private String borrower;

	@Transient
	@Schema(description = "申请部门")
	@Dict(dicCode = "deptCode", dicEntity = Dept.class, dicText = "deptName")
	private String applyDept;
	@Transient
	@Schema(description = "预计归还时间")
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
	private Date planReturnTime;


	@Transient
	private Item item;

	@Transient
	@Schema(description = "单借出流水，批次对应已归还的数量")
	private BigDecimal outFlowLotReturnedSum;//单借出流水，批次对应已归还的数量
}
